package com.hjc.springbootmovies.controller;

import com.hjc.springbootmovies.entity.ModelFsort;
import com.hjc.springbootmovies.service.Impl.FsortServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;


/**
 * Created by IntelliJ IDEA.
 * User: HJC
 * Date: 2019/12/4
 * Time: 14:34
 * To change this template use File | Settings | File Templates.
 */
@Controller
@RequestMapping("/fsort")
public class FsortController {
    @Autowired
    private FsortServiceImpl fsortService;

    @GetMapping("fsortControllerAll")
    public String fsortAll(){
        return "html/fsort/all";
    }

    @GetMapping("fsortControllerAdd")
    public String fsortAdd(){
        return "html/fsort/add";
    }

    @GetMapping("fsortControllerUpdate")
    public String fsortUpdate(Integer sid , Model model){
        model.addAttribute("sid",sid);
        return "html/fsort/update";
    }

    @PostMapping("fsortControllerUpdate2")
    public String fsortUpdate2(ModelFsort modelFsort){
        int count = fsortService.updateFsort(modelFsort);
        return "html/fsort/all";
    }
    @RequestMapping( value = "addFsort" ,method = RequestMethod.POST)
    public String addFsort(ModelFsort modelFsort){
        int count = fsortService.addFsort(modelFsort);
        return "html/fsort/all";
    }

    @RequestMapping( value = "deleteById" ,method = RequestMethod.GET)
    public String deleteById(int sid){
        int count = fsortService.deleteById(sid);
        return "html/fsort/all";
    }

    @RequestMapping( value = "updateFsort" ,method = RequestMethod.POST)
    public String updateFsort(ModelFsort modelFsort){
        int count = fsortService.updateFsort(modelFsort);
        return "html/fsort/all";
    }
}
